<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        /* 正则表达式默认是贪婪的  
        reg=/\d{3,6}/   数字都被替换了
        reg=/\d{3,6}?/   替换3到6
         */
        var str="123456fsfsdljk";
        var reg=/\d{3,6}?/;
        console.log(str.replace(reg,"*"))
    </script>
</body>
</html>